package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Map;

@Mapper
public interface UserMapper {
    @Select("select * from sky_take_out.user where openid=#{openid}")
    public User getByopenId(String openid);

    void insert(User user);

    @Select("select * from sky_take_out.user where id=#{userId}")
    User getById(Long userId);

    @Select("select count(*) from sky_take_out.user where sky_take_out.user.create_time between #{begintime} and #{endtime}")
    Integer countByTime(LocalDateTime begintime, LocalDateTime endtime);

    @Select("select COUNT(*) from sky_take_out.user where create_time <#{endtime}")
    Integer count(LocalDateTime endtime);



    /**
     * 根据动态条件统计用户数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);

}
